package com.jnsw.testkotlin.utils;

import android.content.Context;
import android.widget.Toast;

import com.jnsw.testkotlin.MyApplication;


/**
 * Created by Administrator on 2017/10/26 0026.
 */

public class Tip {
   public  static  Toast toast;

    public static void shortTip(final String tip){
        MyApplication.Companion.getInstance().getAppHandle().post(new Runnable() {
            @Override
            public void run() {
                Short(MyApplication.Companion.getInstance(), tip);
            }
        });
    }
    public static void longTip(final String tip){
        MyApplication.Companion.getInstance().getAppHandle().post(new Runnable() {
            @Override
            public void run() {
                Long(MyApplication.Companion.getInstance(), tip);
            }
        });
    }

    public static void Short(Context context, String tip) {
        if (toast != null){
            toast.setText(tip);
        }else {
            toast =  Toast.makeText(context, tip, Toast.LENGTH_SHORT);
        }

        toast.show();
    }
    public static void Long(Context context,String tip) {
        if (toast != null){
            toast.setText(tip);
        }else {
            toast =  Toast.makeText(context, tip, Toast.LENGTH_LONG);
        }

        toast.show();
    }
}
